package adapter;

import voice.main.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MenuItemAdapter extends BaseAdapter {
	private Context context;
	private final String[] menuValues;
 
	public MenuItemAdapter(Context context, String[] menuValues) {
		this.context = context;
		this.menuValues = menuValues;
	}
 
	public View getView(int position, View convertView, ViewGroup parent) {
 
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 
		View listView;
 
		if (convertView == null) {
			listView = new View(context);
			listView = inflater.inflate(R.layout.menu_item, parent, false);
		} 
		else {
			listView = (View) convertView;
		}
		
		TextView textView = (TextView) listView.findViewById(R.id.list_item_label);
		textView.setText(menuValues[position]);
		
		ImageView imageView = (ImageView) listView.findViewById(R.id.list_item_image);
 
		String menuItem = menuValues[position];
		
		if (menuItem.equals("Chat with YRU")) {
			imageView.setImageResource(R.drawable.speak_icon);
		} 
		else if (menuItem.equals("Phone")) {
			imageView.setImageResource(R.drawable.phone_icon);
		} 
		else if (menuItem.equals("SMS")) {
			imageView.setImageResource(R.drawable.message_icon);
		}
		else if (menuItem.equals("Open Map")) {
			imageView.setImageResource(R.drawable.map_icon);
		}
		else if (menuItem.equals("Get Current Location")) {
			imageView.setImageResource(R.drawable.location_icon);
		}
		else if (menuItem.equals("Open Email")) {
			imageView.setImageResource(R.drawable.email_icon);
		}
		else if (menuItem.equals("Toggle Wifi")) {
			imageView.setImageResource(R.drawable.wifi_icon);
		}
		else if (menuItem.equals("Toggle Cellular")) {
			imageView.setImageResource(R.drawable.cellular_icon);
		}
		else if (menuItem.equals("Toggle Bluetooth")) {
			imageView.setImageResource(R.drawable.bluetooth_icon);
		}
		else if (menuItem.equals("Open Camera")) {
			imageView.setImageResource(R.drawable.camera_icon);
		}
		else if (menuItem.equals("Open Web Browser")) {
			imageView.setImageResource(R.drawable.browser_icon);
		}
		else if (menuItem.equals("Open Facebook")) {
			imageView.setImageResource(R.drawable.facebook_icon);
		}
		else if (menuItem.equals("Open Skype")) {
			imageView.setImageResource(R.drawable.skype_icon);
		}
	
		return listView;
	}
	
	public int getCount() {
		return menuValues.length;
	}
 
	public Object getItem(int position) {
		return null;
	}
	
	public long getItemId(int position) {
		return 0;
	}
 
}